package com.len.controller;

import com.len.base.BaseController;
import com.len.entity.SpTx;
import com.len.service.SpTxService;
import com.len.service.SpYongjinService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

import static cn.hutool.core.util.StrUtil.uuid;

/**
 * (SpTx)表控制层
 *
 * @author makejava
 * @since 2021-03-07 18:04:01
 */
@Controller
@RequestMapping("spTx")
public class SpTxController extends BaseController<SpTx> {
    /**
     * 服务对象
     */
    @Resource
    private SpTxService spTxService;
    @Resource
    private SpYongjinService spYongjinService;
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public SpTx selectOne(String id) {
//        return this.spTxService.queryById(id);
        return null;
    }
    @PostMapping("show")
    public String show() {
//        return this.spTxService.queryById(id);
        return "";
    }
    /**
     * 通过主键查询单条数据
     *
     * @param
     * @return 单条数据
     */
    @PostMapping("selectOne")
    public List<SpTx> getList() {
//        return this.spTxService.queryById(id);
        return spTxService.getList();
    }
    @PostMapping("updateDk")
    public void updateDk(String id){
        spTxService.updateDk(id);
    }

    @PostMapping("insertData")
    public void insertData(String id,String price){
        SpTx spTx = new SpTx();
        spTx.setId(uuid());
        spTx.setDk("1");
        spTx.setAmount(price);
        spTx.setUserId(id);
        spTx.setTxDate(new Date());
        spTxService.insert(spTx);
    }
}
